package com.game;

import java.util.Vector;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.MotionEvent;

public class Scene3 extends Scene {
	
	private Bitmap m_Background;
	private Bitmap m_Planets;
	
	private final int Planet0= 0, Planet1=1;
	
	private Vector<Button> m_PlanetButtons;
	
	public Scene3(SceneManager parent)
	{
		super(parent);
		m_Background = LoadBitmap(R.drawable.scene3_bg);
		m_Planets = LoadBitmap(R.drawable.scene3_planets);
		m_PlanetButtons = new Vector<Button>();
		
		Button auxPlanet;
		auxPlanet = new Button(Planet0, 20, 170, LoadBitmap(R.drawable.scene3_planet_1_on), LoadBitmap(R.drawable.scene3_planet_off_invisible));
		m_PlanetButtons.add(auxPlanet);
	}

	@Override
	public void Draw(Canvas canvas) 
	{
		canvas.drawBitmap(m_Background, 0, 0, null);
		canvas.drawBitmap(m_Planets, 0, 0, null);
		
		for (Button button : m_PlanetButtons) 
		{
			button.Draw(canvas);
		}

	}

	@Override
	public void End() {
		// TODO Auto-generated method stub

	}

	@Override
	public void Start() {
		// TODO Auto-generated method stub

	}

	@Override
	public void Update() {
		for (Button button : m_PlanetButtons) 
		{
			if(button.Used())
			{
				GoToPlanet(button.getID());
			
			}
		}

	}

	@Override
	public boolean handleTouch(MotionEvent event)
	{
		synchronized (mSurfaceHolder) 
		{
			int tx,ty;
			tx = (int)event.getX();
			ty = (int)event.getY();
			
			
			for (Button button : m_PlanetButtons) 
			{
				button.TryTouch(tx, ty);				
			}			
			
		}
		return true;
	}
	
	private void GoToPlanet(int planet)
	{
		mParentSM.ChangeScene(new Scene4(mParentSM,planet))	;	
	}

}
